package ch05.ioc;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
    public void test1(){
        Hello hello = new Hello() ;
        hello.say();
    }

    public void test2(){
        //1.读取配置文件
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("ch05/ioc/ioc.xml") ;
        //2.
        Hello hello = (Hello) applicationContext.getBean("hello") ;
        //3.
        hello.say();
    }

    public  void test3(){
        Person person = new Person() ;
        person.setName("张嘎");
        person.setWords("三天不打小鬼子，手都痒痒！");
        person.show();
    }

    public  void test4(){
        //1.读取配置文件
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("ch05/ioc/ioc.xml" );
        //2.
        Person person = (Person) applicationContext.getBean("person") ;
        person.show();
    }

    public void test5(){
        //1.
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("ch05/ioc/ioc.xml") ;
        Printer printer = (Printer) applicationContext.getBean("printer") ;
        printer.print();
    }

    public static void main(String[] args) {
        Test test = new Test() ;
        test.test5();
    }
}
